/************************************
 * Package: RGcpp					*
 * Authors: Rui Eduardo Gouveia Gil	*
 * Date: 2010						*
 ************************************/
#ifndef __RGCPP_THREADPOOL_H__
#define __RGCPP_THREADPOOL_H__

#include <boost/thread.hpp>

#include "rgcpp/utils/LogHandler.h"
#include "rgcpp/exceptions/Exception.h"
#include "rgcpp/structs/PriorityQueue.h"
#include "rgcpp/sys/ThreadPoolInterface.h"

namespace rgcpp
{

class ThreadPool
{
	private:
		bool running;
		char** buffers;
		boost::mutex mut;
		unsigned int num;
		unsigned int exeNum;
		boost::thread** mThreads;
		boost::condition_variable cond;
		PriorityQueue<ThreadPoolInterface*> priorityQueue;

	public:
		ThreadPool(unsigned int threadNum, unsigned int threadMem=0);
		~ThreadPool();

		void schedule(ThreadPoolInterface* object);

		void operator()();
};

}

#endif
